﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Framework.Web.WebControls;
using Ue.Qcdz.Domain.TheResource;

namespace Ue.Qcdz.UI.Controls.Resources
{
    public class ResourceEdit : SkinnedEntityEdit<Resource>
    {
        #region Overrides of SkinnedControl

        private TextBox tbxNum;
        private TextBox tbxName;
        private string skinName = "~/Admin/Themes/Skins/Resource/ResourceEdit.ascx";
        protected override string GetSkinFileName()
        {
            return skinName;
        }

        #endregion

        #region Overrides of SkinnedEntityEdit<Resource>

        protected override Resource Enttiy
        {
            get
            {
                return new Resource
                    (
                     tbxName.GetValue<string>(),
                     tbxNum.GetValue<int>(),
                    
                     (object) this.EntityKey
                    );
            }
            set
            {
                if (value == null)
                    return;
                tbxNum.SetValue(value.Num);
                tbxName.SetValue(value.Name);
            }
        }

        protected override void InitSkin(Control skin)
        {
            tbxNum = skin.FindControl<TextBox>("tbxNum");
            tbxName = skin.FindControl<TextBox>("tbxName");
        }

        #endregion
    }
}
